<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>进度条</title>
    <style>
        body{
            margin: 0;
            padding: 0;
            width: 100vw;
            height: 100vh;
            display: grid;
            grid-template-rows: 25px 130px;
            grid-template-columns: 350px;
            grid-template-areas: 'div1' 'div2';
            justify-content: center;
            align-content: center;
            background-color: #000;
        }
        .fa{
            grid-area: div1;
            width: 350px;
            height: 25px;
            border: 2px solid #ccc;
            border-radius: 10px;
            box-shadow: 0 0 10px #fff;
            overflow: hidden;
        }
        .son{
            height: 100%;
            border-radius: 10px;
            box-shadow: 0 0 10px #fff;
            background: linear-gradient(to right,rgb(87,74,74),rgb(43,108,134));
            animation: action 3s infinite;
        }
        @keyframes action {
            0%{
                width: 0;
            }
            100%{
                width: 100%;
            }
        }
        .nav{
            grid-area: div2;
            justify-self: center;
            align-self: center;
        }
        .inp{
            width: 60px;
            height: 35px;
            background-color: #000;
            color: #fff;
            border: 1px solid #ccc;
            border-radius: 10px;
            box-shadow: 0 0 5px #fff;;
            font-size: 20px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="fa">
        <div class="son"></div>
    </div>
    <div class="nav">
        <input type="text" class="inp" value="0">
    </div>
    <script>
        let oFa = document.querySelector('.fa');
        let oSon = document.querySelector('.son');
        // clientWidth没有边框误差
        let oInp = document.querySelector('.inp');
        setInterval(()=>{
            let num = `${parseInt(oSon.clientWidth / oFa.clientWidth * 100)}%`;
            oInp.value = num;
        },60)
    </script>
</body>
</html>